﻿namespace Arms.Presentation.Web.Controllers.Shared
{
    using Arms.Application.Modules.Products;
    using Arms.Framework.Validators;
    using Kendo.Mvc.UI;
    using Kendo.Mvc.Extensions;
    using System.Web.Mvc;

    public class ProductPickerController : BaseController
    {
        private IProductQueryService _productQS;

        public ProductPickerController(IProductQueryService productQS)
        {
            _productQS = Validation.Ensure(productQS);
        }

        public ActionResult GetMenuCategories(int menuID)
        {
            return Json(_productQS.GetMenuCategories(menuID), JsonRequestBehavior.AllowGet);
        }

        public ActionResult GetProductClassesByMenuCategory(int menuCategoryID)
        {
            return Json(_productQS.GetProductClassesByMenuCategory(menuCategoryID), JsonRequestBehavior.AllowGet);
        }

        public ActionResult GetProductsByProductClass(int productClassID)
        {
            return Json(_productQS.GetProductsByProductClass(productClassID), JsonRequestBehavior.AllowGet);
        }

        public ActionResult GetProductsByProductClassTest([DataSourceRequest]DataSourceRequest request)
        {
            return Json(_productQS.GetAllProducts().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
    }
}
